﻿@using System.Text.Encodings.Web;
@{

    //success messages
    var successMessages = new List<string>();
    if (TempData[string.Format("Grand.notifications.{0}", NotifyType.Success)] != null)
    {
        successMessages.AddRange(TempData[string.Format("Grand.notifications.{0}", NotifyType.Success)] as IList<string>);
    }
    if (ViewData[string.Format("Grand.notifications.{0}", NotifyType.Success)] != null)
    {
        successMessages.AddRange(ViewData[string.Format("Grand.notifications.{0}", NotifyType.Success)] as IList<string>);
    }

    //error messages
    var errorMessages = new List<string>();
    if (TempData[string.Format("Grand.notifications.{0}", NotifyType.Error)] != null)
    {
        errorMessages.AddRange(TempData[string.Format("Grand.notifications.{0}", NotifyType.Error)] as IList<string>);
    }
    if (ViewData[string.Format("Grand.notifications.{0}", NotifyType.Error)] != null)
    {
        errorMessages.AddRange(ViewData[string.Format("Grand.notifications.{0}", NotifyType.Error)] as IList<string>);
    }
}
@foreach (var message in successMessages)
{
    <script asp-location="Footer">
        $(document).ready(function () {
            displayPopupNotification('@Html.Raw(JavaScriptEncoder.Default.Encode(message))', 'success', false);
        });
    </script>
}
@foreach (var message in errorMessages)
{
    <script asp-location="Footer">
        $(document).ready(function () {
            displayPopupNotification('@Html.Raw(JavaScriptEncoder.Default.Encode(message))', 'error', false);
        });
    </script>
}
<div class="ajax-loading-block-window" style="display: none">
    <div id="loading"><div class="loader"></div></div>
</div>

<div id="bar-notification" class="generalNote"></div>

<a class="popup-action-banner" data-mfp-src="#action_modal_banner" style="display:none"></a>
<div id="action_modal_banner" class="zoom-anim-dialog mfp-hide">
    <div id="action-body-banner"></div>
</div>
<a class="popup-action-form" data-mfp-src="#action_modal_form" style="display:none"></a>
<div id="action_modal_form" class="zoom-anim-dialog mfp-hide">
    <form asp-route="PopupInteractiveForm" method="post" id="interactive-form">
        <div id="action-body-form"></div>
    </form>
</div>
<div class="modal fade" id="ModalAddToCart" tabindex="-1" role="dialog" aria-hidden="true">
</div>
<div class="modal fade" id="ModalQuickView" tabindex="-2" role="dialog" aria-hidden="true">
</div>
<div class="modal fade" id="generalModal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
      <div class="modal-content">
          <div class="modal-header p-0 border-bottom-0">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
              </button>
          </div>
          <div class="modal-body p-0">
              <div id="dialog_error"></div>
              <div id="dialog_success"></div>
          </div>
      </div>
  </div>
</div>
<script asp-location="Footer">
    $(document).ready(function () {
        CustomerAction.init('@Url.Action("CustomerActionEventUrl", "Common")', '@Url.Action("GetActivePopup", "Common")', '@Url.Action("RemovePopup", "Common")');
        CustomerAction.checkActiveUrl('@Context.Request.Path.ToString()', '@Context.Request.Headers["Referer"]');
    });
</script>

@await Component.InvokeAsync("Widget", new { widgetZone = "notifications" })
